package com.huangyi.order.controller;

import com.huangyi.order.api.ProductApi;
import com.huangyi.order.model.ProductInfo;
import com.huangyi.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/product1")
public class ProductApiController {
    @Autowired
    private ProductApi productApi;

    @RequestMapping("/{id}")
    ProductInfo getProductInfo(@RequestParam("id") Integer id) {
        return  productApi.gerProductById(id);
    }

    @RequestMapping("/o1")
    public String returnId (@RequestParam("id") Integer id){
        return productApi.returnId(id);
    }
    @RequestMapping("/o2")
    public String returnId2 (@RequestParam("name") String name,@RequestParam("id") Integer id){
        return productApi.getNameAndId(id,name);
    }
    @RequestMapping("/o3")
    public String returnId3 (ProductInfo productInfo){
        return productApi.returnInfo(productInfo);
    }
    @RequestMapping("/o4")
    public String returnId4 (@RequestBody ProductInfo productInfo){
        return productApi.returnInfoJson(productInfo);
    }

//    @RequestMapping("/{id}")
//    ProductInfo gerProductById(@PathVariable("id") Integer id);
//    @RequestMapping("/p1")
//    String returnId (@RequestParam("id") Integer id);
//    @RequestMapping("/p2")
//    String getNameAndId (@RequestParam("id") Integer id, @RequestParam("name") String name);
//    @RequestMapping("/p3")
//    String returnInfo (ProductInfo productInfo);
//    @RequestMapping("/p4")
//    String returnInfoJson (ProductInfo productInfo);
}
